#include "StdAfx.h"
#include "CircuitArc.h"


CCircuitArc::CCircuitArc(void)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblRadius = 0;
	m_borderWidth = 0;
	m_dblStartAngle = 0;
	m_dblEndAngle = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
}

CCircuitArc::CCircuitArc(const CCircuitArc *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX = pEntityObj->GetPosX();
	m_dblPosY = pEntityObj->GetPosY();
	m_dblRadius = pEntityObj->GetRadius();
	m_borderWidth = pEntityObj->GetBorderWidth();
	m_dblStartAngle = pEntityObj->GetStartAngle();
	m_dblEndAngle = pEntityObj->GetEndAngle();
	m_dblColor[0] = pEntityObj->GetColorR();
	m_dblColor[1] = pEntityObj->GetColorG();
	m_dblColor[2] = pEntityObj->GetColorB();
	m_bSelected = pEntityObj->IsSelected();
}

CCircuitArc::CCircuitArc(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblPosX = 0;
	m_dblPosY = 0;
	m_dblRadius = 0;
	m_borderWidth = 0;
	m_dblStartAngle = 0;
	m_dblEndAngle = 0;
	m_dblColor[0] = 0;
	m_dblColor[1] = 0;
	m_dblColor[2] = 0;
	m_bSelected = false;
}

CCircuitArc::~CCircuitArc(void)
{
}

void CCircuitArc::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblRadius;
		ar << m_borderWidth;
		ar << m_dblStartAngle;
		ar << m_dblEndAngle;
		ar << m_dblColor[0];
		ar << m_dblColor[1];
		ar << m_dblColor[2];
		ar << m_bSelected;
	}
	else
	{
		ar >> m_dblPosX;
		ar >> m_dblPosY;
		ar >> m_dblRadius;
		ar >> m_borderWidth;
		ar >> m_dblStartAngle;
		ar >> m_dblEndAngle;
		ar >> m_dblColor[0];
		ar >> m_dblColor[1];
		ar >> m_dblColor[2];
		ar >> m_bSelected;
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitArc::Clone() const
{
	return new CCircuitArc(this);
}

void CCircuitArc::Transform(const CMatrix transf)
{

}

bool CCircuitArc::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitArc::Clear()
{

}

void CCircuitArc::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitArc::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitArc::CreateDisplayObj(long lLayerId)
{
	CCircuitArcDisObj *pArcDis = new CCircuitArcDisObj(this);
	pArcDis->SetLayerId(lLayerId);

	return pArcDis;
}

void CCircuitArc::CalcBox()
{
	m_minX = m_dblPosX - m_dblRadius;
	m_minY = m_dblPosY - m_dblRadius;
	m_maxX = m_dblPosX + m_dblRadius;
	m_maxY = m_dblPosY + m_dblRadius;
}

eCircuitUnitEntType CCircuitArc::GetUnitType() const
{
	return CIRCUIT_ARC;
}

bool CCircuitArc::IsSelected() const
{
	return m_bSelected;
}

double CCircuitArc::GetPosX() const
{
	return m_dblPosX;
}

double CCircuitArc::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitArc::GetRadius() const
{
	return m_dblRadius;
}

double CCircuitArc::GetBorderWidth() const
{
	return m_borderWidth;
}

double CCircuitArc::GetStartAngle() const
{
	return m_dblStartAngle;
}

double CCircuitArc::GetEndAngle() const
{
	return m_dblEndAngle;
}

double CCircuitArc::GetColorR() const
{
	return m_dblColor[0];
}

double CCircuitArc::GetColorG() const
{
	return m_dblColor[1];
}

double CCircuitArc::GetColorB() const
{
	return m_dblColor[2];
}

void CCircuitArc::SetSelected(bool bFlag) 
{
	m_bSelected = bFlag;
}

void CCircuitArc::SetPosX(double posX) 
{
	m_dblPosX = posX;
}

void CCircuitArc::SetPosY(double posY) 
{
	m_dblPosY = posY;
}

void CCircuitArc::SetRadius(double rad) 
{
	m_dblRadius = rad;
}

void CCircuitArc::SetBorderWidth(double dblWidth) 
{
	m_borderWidth = dblWidth;
}

void CCircuitArc::SetStartAngle(double dblAngle) 
{
	m_dblStartAngle = dblAngle;
}

void CCircuitArc::SetEndAngle(double dblAngle)
{
	m_dblEndAngle = dblAngle;
}

void CCircuitArc::SetColorR(double colR) 
{
	m_dblColor[0] = colR;
}

void CCircuitArc::SetColorG(double colG) 
{
	m_dblColor[1] = colG;
}

void CCircuitArc::SetColorB(double colB) 
{
	m_dblColor[2] = colB;
}